﻿package morn.core.components
{
    import flash.display.*;

    public class Box extends Component implements IBox
    {

        public function Box()
        {
            mouseChildren = true;
            return;
        }// end function

        public function addElement(param1:DisplayObject, param2:Number, param3:Number) : void
        {
            param1.x = param2;
            param1.y = param3;
            addChild(param1);
            return;
        }// end function

        public function addElementAt(param1:DisplayObject, param2:int, param3:Number, param4:Number) : void
        {
            param1.x = param3;
            param1.y = param4;
            addChildAt(param1, param2);
            return;
        }// end function

        public function addElements(param1:Array) : void
        {
            var _loc_4:DisplayObject = null;
            var _loc_2:int = 0;
            var _loc_3:* = param1.length;
            while (_loc_2 < _loc_3)
            {
                
                _loc_4 = param1[_loc_2];
                addChild(_loc_4);
                _loc_2++;
            }
            return;
        }// end function

        public function removeElement(param1:DisplayObject) : void
        {
            if (param1 && contains(param1))
            {
                removeChild(param1);
            }
            return;
        }// end function

        public function removeAllChild(param1:DisplayObject = null) : void
        {
            var _loc_2:* = numChildren - 1;
            while (_loc_2 > -1)
            {
                
                if (param1 != getChildAt(_loc_2))
                {
                    removeChildAt(_loc_2);
                }
                _loc_2 = _loc_2 - 1;
            }
            return;
        }// end function

        public function insertAbove(param1:DisplayObject, param2:DisplayObject) : void
        {
            this.removeElement(param1);
            var _loc_3:* = getChildIndex(param2);
            addChildAt(param1, Math.min((_loc_3 + 1), numChildren));
            return;
        }// end function

        public function insertBelow(param1:DisplayObject, param2:DisplayObject) : void
        {
            this.removeElement(param1);
            var _loc_3:* = getChildIndex(param2);
            addChildAt(param1, Math.max(_loc_3, 0));
            return;
        }// end function

        override public function set dataSource(param1:Object) : void
        {
            var _loc_2:String = null;
            var _loc_3:Component = null;
            _dataSource = param1;
            for (_loc_2 in param1)
            {
                
                _loc_3 = getChildByName(_loc_2) as Component;
                if (_loc_3)
                {
                    _loc_3.dataSource = param1[_loc_2];
                }
            }
            return;
        }// end function

    }
}
